<template>
	<view class="content">
		<view class="header">
			<view class="top-title">
				当前多多券（元）
			</view>
			<view class="bottom-title">
				{{balance}}
			</view>
		</view>
		<view class="box">
			<view class="title">
				账户充值
			</view>
			<input placeholder="¥请输入充值金额" placeholder-class="placeholder" class="input" type="number" maxlength="8"
				v-model="money" />
			<view class="tips">
				充值金额不能低于500
			</view>
		</view>
		<view class="btn" :class="{'active':!hasMoney}" @tap="goRechargeType">
			立即充值
		</view>
		<!-- <view class="top">
			<view class="typeContent">
				<view class="change">选择充值类型</view>
			</view>
			<view class="currency">多多券</view>
		</view>
		<view class="balanceContent">
			<span>多多券</span>{{balance}}
		</view>
		<view class="text">充值金额</view>
		<view class="inputContent">
			<view class="icon">¥</view>
			<input placeholder="请输入充值金额" placeholder-class="placeholder" class="input" type="number" maxlength="8" v-model="money" />
		</view>
		<view class="submit" @tap="goRechargeType">充值</view> -->
	</view>
</template>

<script>
	import {
		userBalance
	} from '../../api/api.js'
	export default {
		data() {
			return {
				balance: '',
				money: ''
			}
		},
		onShow() {
			// 获取用户多多券
			this.getUserBalance()
		},
		computed: {
			hasMoney() {
				return !this.money||this.money ==0
			}
		},
		methods: {
			// 获取用户多多券
			getUserBalance() {
				let data = {}
				userBalance(data).then(res => {
					this.balance = res.data.balance
				})
			},
			// 查看充值记录
			checkRecord() {
				uni.navigateTo({
					url: './rechargeRecord'
				})
			},
			// 充值
			goRechargeType() {
				if(!this.money||this.money==0){
					uni.showToast({
						title:"请输入充值金额",
						icon:"none"
					})
					return
				}
				if(this.money < 500){
					uni.showToast({
						title:"充值金额不能低于500",
						icon:"none"
					})
					return
				}
				uni.navigateTo({
					url:'/pages/recharge/rechargeSelect?money=' + this.money + "&balance=" + this.balance
				})
			}
		}
	}
</script>

<style lang="less">
	page {
		background-color: #F6F6F7;

	}

	.content {
		.header {
			width: 100%;
			height: 100rpx;
			background: #00C538;
			display: flex;
			flex-direction: column;
			justify-content: center;
			align-items: center;

			.top-title {
				font-weight: 400;
				font-size: 20rpx;
				color: #FFFFFF;
				margin-bottom: 20rpx;
			}

			.bottom-title {
				font-weight: bold;
				font-size: 36rpx;
				color: #FFFFFF;
			}
		}

		.box {
			width: 710rpx;
			height: 196rpx;
			background: #FFFFFF;
			border-radius: 8rpx;
			margin: 20rpx;
			padding: 28rpx;
			box-sizing: border-box;

			.title {
				font-weight: 400;
				font-size: 28rpx;
				color: #000000;
				margin-bottom: 22rpx;
			}

			.input {
				height: 60rpx;
				border-bottom: 2rpx solid #F9F9F9;
			}

			.tips {
				font-weight: 500;
				font-size: 20rpx;
				color: #B9585D;
				margin-top: 20rpx;
			}
		}

		.btn {
			width: 710rpx;
			height: 88rpx;
			background: #ECEAEA;
			border-radius: 88rpx;
			display: flex;
			justify-content: center;
			align-items: center;
			font-weight: 500;
			font-size: 36rpx;
			color: #FFFFFF;
			margin: 0 auto;
		}

		.active {
			background: #00C538;
		}
	}

	.content {
		.top {
			padding: 30rpx 30rpx 0 30rpx;
			width: 690rpx;
			height: 160rpx;
			background-color: #FE3B33;

			.typeContent {
				display: flex;
				align-items: center;
				justify-content: space-between;

				.change {
					font-size: 30rpx;
					font-family: PingFangSC-Regular, PingFang SC;
					font-weight: 400;
					color: #A7CBFF;
					line-height: 42rpx;
				}

				.cords {
					text-align: center;
					width: 140rpx;
					height: 56rpx;
					border-radius: 8rpx;
					border: 1rpx solid #FFFFFF;
					font-size: 26rpx;
					font-family: PingFangSC-Regular, PingFang SC;
					font-weight: 400;
					color: #FFFFFF;
					line-height: 56rpx;
				}
			}

			.currency {
				margin-top: 20rpx;
				font-size: 32rpx;
				font-family: PingFangSC-Medium, PingFang SC;
				font-weight: 500;
				color: #FFFFFF;
				line-height: 45rpx;
			}
		}

		// 多多券
		.balanceContent {
			width: 100%;
			height: 120rpx;
			line-height: 120rpx;
			border-bottom: 10rpx solid #F5F5F5;
			font-size: 36rpx;
			font-family: PingFangSC-Medium, PingFang SC;
			font-weight: 500;
			color: #CA0000;

			span {
				margin: 0 24rpx 0 30rpx;
				font-size: 30rpx;
				font-family: PingFangSC-Medium, PingFang SC;
				font-weight: 500;
				color: #000000;
			}
		}

		.text {
			margin: 36rpx 0 0 34rpx;
			font-size: 30rpx;
			font-family: PingFangSC-Medium, PingFang SC;
			font-weight: 500;
			color: #000000;
			line-height: 42rpx;
		}

		.inputContent {
			position: relative;

			.icon {
				left: 30rpx;
				top: 15rpx;
				position: absolute;
				font-size: 32rpx;
				font-family: PingFangSC-Medium, PingFang SC;
				font-weight: 500;
				color: #000000;
			}

			.input {
				padding-left: 30rpx;
				margin: 30rpx 0 0 30rpx;
				width: 660rpx;
				height: 70rpx;
				border-bottom: 1px solid #E5E5E5;
			}

			.placeholder {
				font-size: 28rpx;
				font-family: PingFangSC-Regular, PingFang SC;
				font-weight: 400;
				color: #999999;
				line-height: 40rpx;
			}
		}

		.submit {
			margin: 320rpx 0 0 30rpx;
			text-align: center;
			line-height: 90rpx;
			width: 690rpx;
			height: 90rpx;
			background: #FE3B33;
			border-radius: 45rpx;
			font-size: 28rpx;
			font-family: PingFangSC-Medium, PingFang SC;
			font-weight: 500;
			color: #FFFFFF;
		}
	}
</style>